<template>
    <Form ref="customerInfoForm" :model="customerInfoForm" :label-width="120" inline>
        <Row>
            <h3>基本信息：</h3>
        </Row>
        <br>
        <FormItem label="申请编号" prop="">
            <Input v-model="customerInfoForm.loanId" disabled></Input>
        </FormItem>
        <FormItem label="客户姓名" prop="">
            <Input v-model="customerInfoForm.custName" disabled></Input>
        </FormItem>
        <FormItem label="雇佣类型" prop="">
            <Select v-model="customerInfoForm.customerType" class="task-process-detail-select" disabled>
                <Option v-for="item in selectEmployTypeBasicData" :value="item.code" :key="item.code">{{ item.name }}</Option>
            </Select>
        </FormItem>
        <!-- <FormItem label="曾用名" prop="">
            <Input v-model="customerInfoForm."></Input>
        </FormItem> -->
        <FormItem label="身份证号码" prop="">
            <Input v-model="customerInfoForm.custCardNo" disabled></Input>
        </FormItem>
        <FormItem label="发证机构" prop="">
            <Input v-model="customerInfoForm.custCardIssuer" disabled></Input>
        </FormItem>
        <FormItem label="证件有效期" prop="">
            <DatePicker v-model="customerInfoForm.custCardStartTime" :value="customerInfoForm.custCardStartTime" type="date" disabled></DatePicker>——
            <DatePicker v-model="customerInfoForm.custCardEndTime" :value="customerInfoForm.custCardEndTime" type="date" disabled></DatePicker>
        </FormItem>
        <FormItem label="性别" prop="">
            <Input v-model="customerInfoForm.custSex" disabled></Input>
        </FormItem>
        <FormItem label="出生日期" prop="">
            <DatePicker v-model="customerInfoForm.custBirthDate" :value="customerInfoForm.custBirthDate" type="date" disabled></DatePicker>
        </FormItem>
        <FormItem label="年龄" prop="">
            <Input v-model="customerInfoForm.custAge" disabled></Input>
        </FormItem>
        <FormItem label="婚姻状况" prop="">
            <Select v-model="customerInfoForm.maritalStatus" class="task-process-detail-select" disabled>
                <Option v-for="item in selectMaritalStatusBasicData" :value="item.code" :key="item.code">{{ item.name }}</Option>
            </Select>
        </FormItem>
        <FormItem label="手机号码" prop="">
            <Input v-model="customerInfoForm.mobileNo" disabled></Input>
        </FormItem>
        <FormItem label="教育程度" prop="">
            <Select v-model="customerInfoForm.eductionLevelId" class="task-process-detail-select" disabled>
                <Option v-for="item in selectEducationLevelBasicData" :value="item.code" :key="item.code">{{ item.name }}</Option>
            </Select>
        </FormItem>
        <FormItem label="居住类型" prop="">
            <Select v-model="customerInfoForm.homeTypeId" class="task-process-detail-select" disabled>
                <Option v-for="item in selectLiveTypeBasicData" :value="item.code" :key="item.code">{{ item.name }}</Option>
            </Select>
        </FormItem>
        <FormItem label="租赁时长" prop="">
            <DatePicker v-model="customerInfoForm.homeRentStartDate" :value="customerInfoForm.homeRentStartDate" type="date" disabled></DatePicker>——
            <DatePicker v-model="customerInfoForm.homeRentEndDate" :value="customerInfoForm.homeRentEndDate" type="date" disabled></DatePicker>
        </FormItem>
        <FormItem label="月租金" prop="">
            <Input v-model="customerInfoForm.homeMthRent" disabled></Input>
        </FormItem>
        <!-- <FormItem label="现居地址（省）" prop="">
            <Select v-model="customerInfoForm.curHomeProvince" class="task-process-detail-select">
                <Option v-for="item in selectProvinceBasicData" :value="item.code" :key="item.code">{{ item.name }}</Option>
            </Select>
        </FormItem>
        <FormItem label="现居地址（市）" prop="">
            <Select v-model="customerInfoForm.curHomeCity" class="task-process-detail-select">
                <Option v-for="item in selectCityBasicData" :value="item.code" :key="item.code">{{ item.name }}</Option>
            </Select>
        </FormItem>
        <FormItem label="现居地址（区/县）" prop="">
            <Select v-model="customerInfoForm.curHomeCounty" class="task-process-detail-select">
                <Option v-for="item in selectRegionBasicData" :value="item.code" :key="item.code">{{ item.name }}</Option>
            </Select>
        </FormItem> -->
        <FormItem label="邮箱地址" prop="">
            <Input v-model="customerInfoForm.email" disabled></Input>
        </FormItem>

        <Row type="flex" align="middle" disabled>
            <Col span="1">
            <span>现居地址</span>
            </Col>
            <Col span="7">
            <al-selector v-model="curHomeAry" data-type="code" level="2" disabled/>
            </Col>
        </Row>
        <Row>
            <Col span="8">
            <FormItem label="现居地址（路/街）" prop="">
                <Input v-model="customerInfoForm.curHomeStreet" style="width:150px;" disabled></Input>
            </FormItem>
            </Col>
            <Col span="2" style="text-align: center"></Col>
            <Col span="16">
            <FormItem label="现居地址（详细）" prop="">
                <Input v-model="customerInfoForm.curHomeAddress" style="width:300px;" disabled></Input>
            </FormItem>
            </Col>
        </Row>
        <Row>
            <h3>工作信息：</h3>
        </Row>
        <br>
        <FormItem label="工作单位名称" prop="">
            <Input v-model="customerInfoForm.companyName" disabled></Input>
        </FormItem>
        <FormItem label="所在部门" prop="">
            <Input v-model="customerInfoForm.companyDept" disabled></Input>
        </FormItem>
        <FormItem label="职务名称" prop="">
            <Input v-model="customerInfoForm.companyPositionType" disabled></Input>
        </FormItem>
        <FormItem label="公司类型" prop="">
            <Select v-model="customerInfoForm.companyTypeId" class="task-process-detail-select" disabled>
                <Option v-for="item in selectCompanyTypeBasicData" :value="item.code" :key="item.code">{{ item.name }}</Option>
            </Select>
        </FormItem>
        <FormItem label="公司电话" prop="">
            <Row>
                <Col span="4">
                <Input v-model="customerInfoForm.companyCode" disabled></Input>
                </Col>
                <Col span="1" style="text-align: center">——</Col>
                <Col span="6">
                <Input v-model="customerInfoForm.companyTel" disabled></Input>
                </Col>
                <Col span="1" style="text-align: center">——</Col>
                <Col span="4">
                <Input v-model="customerInfoForm.companyExtension" disabled></Input>
                </Col>
            </Row>
        </FormItem>
        <FormItem label="现单位工作年限" prop="">
            <Select v-model="customerInfoForm.workLength" class="task-process-detail-select" disabled>
                <Option v-for="item in selectWorkTimeTypeBasicData" :value="item.code" :key="item.code">{{ item.name }}</Option>
            </Select>
        </FormItem>
        <FormItem label="月收入" prop="">
            <Select v-model="customerInfoForm.selfMthIncomingCde" class="task-process-detail-select" disabled>
                <Option v-for="item in selectIncomeTypeBasicData" :value="item.code" :key="item.code">{{ item.name }}</Option>
            </Select>
        </FormItem>
        <!-- <FormItem label="公司地址（省）" prop="">
            <Select v-model="customerInfoForm.companyProvince" class="task-process-detail-select">
                <Option v-for="item in selectProvinceBasicData" :value="item.code" :key="item.code">{{ item.name }}</Option>
            </Select>
        </FormItem>
        <FormItem label="公司地址（市）" prop="">
            <Select v-model="customerInfoForm.companyCity" class="task-process-detail-select">
                <Option v-for="item in selectCityBasicData" :value="item.code" :key="item.code">{{ item.name }}</Option>
            </Select>
        </FormItem>
        <FormItem label="公司地址（区/县）" prop="">
            <Select v-model="customerInfoForm.companyCounty" class="task-process-detail-select">
                <Option v-for="item in selectRegionBasicData" :value="item.code" :key="item.code">{{ item.name }}</Option>
            </Select>
        </FormItem> -->

        <Row type="flex" align="middle">
            <Col span="1">
            <span>公司地址</span>
            </Col>
            <Col span="7">
            <al-selector v-model="curCompanyAry" data-type="code" level="2" disabled/>
            </Col>
            <Col span="6">
            <FormItem label="公司地址（路/街）" prop="">
                <Input v-model="customerInfoForm.companyStreet" style="width:150px;" disabled></Input>
            </FormItem>
            </Col>
        </Row>
        <Row>
            <Col span="1" style="text-align: center"></Col>
            <Col span="12">
            <FormItem label="公司地址（详细）" prop="">
                <Input v-model="customerInfoForm.companyAddress" style="width:300px;" disabled></Input>
            </FormItem>
            </Col>
        </Row>
        <FormItem label="第二职业" prop="">
            <Select v-model="customerInfoForm.secondWorkTypeCode" class="task-process-detail-select" disabled>
                <Option v-for="item in selectSecondCareerBasicData" :value="item.code" :key="item.code">{{ item.name }}</Option>
            </Select>
        </FormItem>
        <FormItem label="第三职业" prop="">
            <Select v-model="customerInfoForm.thirdWorkTypeCode" class="task-process-detail-select" disabled>
                <Option v-for="item in selectThridCareerBasicData" :value="item.code" :key="item.code">{{ item.name }}</Option>
            </Select>
        </FormItem>
        <div v-if="customerInfoForm.customerType==1">
            <Row>
                <h3>自雇补充：</h3>
            </Row>
            <br>
            <FormItem label="法人代表" prop="">
                <Input v-model="customerInfoForm.businessLegalPerson" disabled></Input>
            </FormItem>
            <FormItem label="持股比例" prop="">
                <Input v-model="customerInfoForm.shareholdingRate" placeholder="%" disabled></Input>
            </FormItem>
            <FormItem label="公司注册时间" prop="">
                <DatePicker v-model="customerInfoForm.companyRegistrationDate" :value="customerInfoForm.companyRegistrationDate" type="date" disabled></DatePicker>
            </FormItem>
            <FormItem label="经营范围" prop="">
                <Input v-model="customerInfoForm.businessScope" disabled></Input>
            </FormItem>
            <FormItem label="人事部联系人" prop="">
                <Input v-model="customerInfoForm.personnelDeptContactor" disabled></Input>
            </FormItem>
            <FormItem label="人事部联系电话" prop="">
                <Row>
                    <Col span="4">
                    <Input v-model="customerInfoForm.personnelDeptContactorCode" disabled></Input>
                    </Col>
                    <Col span="1" style="text-align: center">——</Col>
                    <Col span="6">
                    <Input v-model="customerInfoForm.personnelDeptContactorTel" disabled></Input>
                    </Col>
                    <Col span="1" style="text-align: center">——</Col>
                    <Col span="4">
                    <Input v-model="customerInfoForm.personnelDeptContactorExtension" disabled></Input>
                    </Col>
                </Row>
            </FormItem>
            <FormItem label="注册资本" prop="">
                <Input v-model="customerInfoForm.registeredCapital" placeholder="万元" disabled></Input>
            </FormItem>
            <FormItem label="营业执照号码" prop="">
                <Input v-model="customerInfoForm.businessLicenseNo" disabled></Input>
            </FormItem>
            <FormItem label="贷款投向" prop="">
                <Select v-model="customerInfoForm.loanInvestmentCode" class="task-process-detail-select" @on-change="renderInvestmentDetailList" disabled>
                    <Option v-for="item in selectLoanInvestmentBasicData" :value="item.code" :key="item.code">{{ item.name }}</Option>
                </Select>
            </FormItem>
            <FormItem label="投向明细" prop="">
                <Select v-model="customerInfoForm.investmentDetailCode" class="task-process-detail-select" disabled>
                    <Option v-for="item in selectInvestmentDetailBasicData" :value="item.code" :key="item.code">{{ item.name }}</Option>
                </Select>
            </FormItem>
            <FormItem label="企业规模" prop="">
                <Select v-model="customerInfoForm.enterpriseScaleCode" class="task-process-detail-select" disabled>
                    <Option v-for="item in selectEnterpriseScaleBasicData" :value="item.code" :key="item.code">{{ item.name }}</Option>
                </Select>
            </FormItem>
        </div>

        <Row>
            <h3>联系人信息：</h3>
            <!-- <div style="float:right;">
                <Button type="primary" icon="android-add" style="width:60px;" @click="addContactDefaultEmptyRow" disabled></Button>
            </div> -->
        </Row>
        <Table :columns="columns1" :data="contactData"></Table>
        <br>
        <Row>
            <h3>联系人验证结果：</h3>
            <!-- <div style="float:right;">
                <Button type="primary">刷新</Button>
                <Button type="primary">保存</Button>
            </div> -->
        </Row>
        <Table :columns="columns2" :data="contactChkData"></Table>
        <br>
        <Row>
            <h3>电核录入：</h3>
            <!-- <div style="float:right;">
                <Button type="primary" icon="android-add" style="width:60px;" @click="addPhoneChkDefaultEmptyRow" disabled></Button>
                <Button type="primary" disabled>保存</Button>
            </div> -->
        </Row>
        <Table :columns="columns3" :data="phoneChkData"></Table>
        <!-- <Row>
            <div align="center">
                <Button type="primary" @click="submitForm" disabled>保存</Button>
            </div>
        </Row> -->
    </Form>
</template>

<script>
import alSelector from '../../components/al-selector.vue'
import loanInvestmentData from '../../approval-management/task-processing/loan_investment_data.js'

export default {
  components: {
    alSelector
  },
  name: 'customer-info-form',
  data () {
    return {
      itemName: null,
      baseUrl: this.$appContext.marvels_core_approve,
      $ajax: null,
      curLoanId: '111',
      customerInfoForm: {},
      curHomeAry: [], // 现居住地（省，市，县）
      curCompanyAry: [], // 公司住地（省，市，县）
      columns1: [
        {
          title: '序号',
          type: 'index',
          width: 60,
          align: 'center'
        },
        {
          align: 'center',
          title: '联系人姓名',
          key: 'contactName'
          // render: function (h, params) {
          //   const vm = this
          //   return h('Input', {
          //     props: {
          //       type: 'text',
          //       value: params.row.contactName,
          //       disabled: true
          //     },
          //     on: {
          //       'on-change' (e) {
          //         vm.initTempContactDataObject(params)
          //         vm.$set(vm.tempContactData[params.index], 'contactName', e.target.value)
          //       }
          //     }
          //   })
          // }.bind(this)
        },
        {
          align: 'center',
          title: '与客户关系',
          key: 'relationCode'
          // render: function (h, params) {
          //   const vm = this
          //   return h('Select', {
          //     props: {
          //       'label-in-value': true,
          //       value: vm.tempContactData[params.index] ? vm.tempContactData[params.index].relationCode : params.row.relationCode
          //     },
          //     on: {
          //       'on-change' (v) {
          //         vm.initTempContactDataObject(params)
          //         vm.$set(vm.tempContactData[params.index], 'relationCode', v.value)
          //         vm.$set(vm.tempContactData[params.index], 'relationName', v.label)
          //       }
          //     }
          //   }, vm.renderRelationSelect(h, params)
          //   )
          // }.bind(this)

        },
        {
          align: 'center',
          title: '手机号码',
          key: 'contactMobile'
          // render: function (h, params) {
          //   const vm = this
          //   return h('Input', {
          //     props: {
          //       type: 'text',
          //       value: params.row.contactMobile,
          //       disabled: true
          //     },
          //     on: {
          //       'on-change' (e) {
          //         vm.initTempContactDataObject(params)
          //         vm.$set(vm.tempContactData[params.index], 'contactMobile', e.target.value)
          //       }
          //     }
          //   })
          // }.bind(this)
        },
        {
          align: 'center',
          title: '是否紧急联系人',
          key: 'isEmergencyContact'
          // render: function (h, params) {
          //   const vm = this
          //   return h('Select', {
          //     props: {
          //       value: params.row.isEmergencyContact
          //     },
          //     on: {
          //       'on-change' (value) {
          //         vm.initTempContactDataObject(params)
          //         vm.$set(vm.tempContactData[params.index], 'isEmergencyContact', value)
          //       }
          //     }
          //   }, this.selectEmergencyContactData.map(function (item) {
          //     return h('Option', {
          //       props: {
          //         value: item.code
          //       }
          //     }, item.name)
          //   })
          //   )
          // }.bind(this)
        }
      ],
      contactData: [],
      tempContactData: [],
      contactEmptyRowData: {
        contactName: null,
        relationCode: null,
        relationName: null,
        contactMobile: null,
        isEmergencyContact: null
      },
      selectEmergencyContactData: [
        {
          code: 0,
          name: '否'
        },
        {
          code: 1,
          name: '是'
        }
      ],
      columns2: [
        {
          title: '序号',
          type: 'index',
          width: 60,
          align: 'center'
        },
        {
          align: 'center',
          title: '联系人姓名',
          key: 'contactName'
        },
        {
          align: 'center',
          title: '支付宝验证结果',
          key: 'aliPayCheckResult'
          // render: function (h, params) {
          //   const vm = this
          //   return h('RadioGroup', {
          //     props: {
          //       value: vm.tempContactChkData[params.index].aliPayCheckResult

          //     },
          //     on: {
          //       'on-change' (val) {
          //         vm.initTempContactChkDataObject(params)
          //         vm.$set(vm.tempContactChkData[params.index], 'aliPayCheckResult', val)
          //         if (val === '0') {
          //           vm.$set(vm.tempContactChkData[params.index], 'aliPayCheckRemark', null)
          //         }
          //       }
          //     }
          //   }, this.selectRadioGroup1.map(function (item) {
          //     return h('Radio', {
          //       props: {
          //         label: item.code
          //       }
          //     }, item.name)
          //   }))
          // }.bind(this)
        },
        {
          align: 'center',
          title: '支付宝验证备注',
          key: 'aliPayCheckRemark'
          // render: function (h, params) {
          //   const vm = this
          //   return h('Input', {
          //     props: {
          //       type: 'text',
          //       value: vm.tempContactChkData[params.index].aliPayCheckRemark,
          //       disabled: vm.tempContactChkData[params.index] ? vm.tempContactChkData[params.index].aliPayCheckResult === '0' : false
          //     },
          //     on: {
          //       'on-change' (e) {
          //         vm.initTempContactChkDataObject(params)
          //         vm.$set(vm.tempContactChkData[params.index], 'aliPayCheckRemark', e.target.value)
          //       }
          //     }
          //   })
          // }.bind(this)
        },
        {
          align: 'center',
          title: '微信验证结果',
          key: 'wechatCheckResult'
          // render: function (h, params) {
          //   var vm = this
          //   return h('RadioGroup', {
          //     props: {
          //       value: vm.tempContactChkData[params.index].wechatCheckResult
          //     },
          //     on: {
          //       'on-change' (val) {
          //         vm.initTempContactChkDataObject(params)
          //         vm.$set(vm.tempContactChkData[params.index], 'wechatCheckResult', val)
          //         if (val === '0') {
          //           vm.$set(vm.tempContactChkData[params.index], 'wechatCheckRemark', null)
          //         }
          //       }
          //     }
          //   }, this.selectRadioGroup1.map(function (item) {
          //     return h('Radio', {
          //       props: {
          //         label: item.code
          //       }
          //     }, item.name)
          //   }))
          // }.bind(this)
        },
        {
          align: 'center',
          title: '微信验证备注',
          key: 'wechatCheckRemark'
          // render: function (h, params) {
          //   const vm = this
          //   return h('Input', {
          //     props: {
          //       type: 'text',
          //       value: vm.tempContactChkData[params.index].wechatCheckRemark,
          //       disabled: false
          //     },
          //     on: {
          //       'on-change' (e) {
          //         vm.initTempContactChkDataObject(params)
          //         vm.$set(vm.tempContactChkData[params.index], 'wechatCheckRemark', e.target.value)
          //       }
          //     }
          //   })
          // }.bind(this)
        }
      ],
      contactChkData: [],
      tempContactChkData: [],
      contactChkEmptyRowData: {
        loanApplyContactId: null,
        contactName: null,
        aliPayCheckResult: null,
        aliPayCheckRemark: null,
        wechatCheckResult: null,
        wechatCheckRemark: null
      },
      selectRadioGroup1: [
        {
          code: '0',
          name: '无'
        },
        {
          code: '1',
          name: '有'
        }
      ],
      columns3: [
        {
          align: 'center',
          title: '电话类型',
          key: 'pohneTypeCode'
          // render: function (h, params) {
          //   const vm = this
          //   return h('Select', {
          //     props: {
          //       value: params.row.pohneTypeCode,
          //       disabled: !!params.row.id
          //     },
          //     on: {
          //       'on-change' (value) {
          //         vm.initTempPhoneChkDataObject(params)
          //         params.row.contactName = ''
          //         params.row.phoneNo = ''
          //         vm.$set(vm.tempPhoneChkData[params.index], 'contactName', '')
          //         vm.$set(vm.tempPhoneChkData[params.index], 'phoneNo', '')
          //         if (vm.contactData && vm.contactData.length > 0) {
          //           for (var i in vm.contactData) {
          //             if (value === vm.contactData[i].relationCode) {
          //               params.row.contactName = vm.contactData[i].contactName
          //               params.row.phoneNo = vm.contactData[i].contactMobile
          //               vm.$set(vm.tempPhoneChkData[params.index], 'contactName', vm.contactData[i].contactName)
          //               vm.$set(vm.tempPhoneChkData[params.index], 'phoneNo', vm.contactData[i].contactMobile)
          //               break
          //             }
          //           }
          //         }
          //         vm.$set(vm.tempPhoneChkData[params.index], 'pohneTypeCode', value)
          //       }
          //     }
          //   }, this.selectRelationAllBasicData.map(function (item) {
          //     return h('Option', {
          //       props: {
          //         value: item.code
          //       }
          //     }, item.name)
          //   })
          //   )
          // }.bind(this)
        },
        {
          align: 'center',
          title: '联系人姓名',
          key: 'contactName'
          // render: function (h, params) {
          //   const vm = this
          //   return h('Input', {
          //     props: {
          //       type: 'text',
          //       value: params.row.contactName,
          //       disabled: !!params.row.id
          //     },
          //     on: {
          //       'on-change' (e) {
          //         vm.initTempPhoneChkDataObject(params)
          //         vm.$set(vm.tempPhoneChkData[params.index], 'contactName', e.target.value)
          //       }
          //     }
          //   })
          // }.bind(this)
        },
        {
          align: 'center',
          title: '电话号码',
          key: 'phoneNo'
          // render: function (h, params) {
          //   const vm = this
          //   return h('Input', {
          //     props: {
          //       type: 'text',
          //       value: params.row.phoneNo,
          //       disabled: !!params.row.id
          //     },
          //     on: {
          //       'on-change' (e) {
          //         vm.initTempPhoneChkDataObject(params)
          //         vm.$set(vm.tempPhoneChkData[params.index], 'phoneNo', e.target.value)
          //       }
          //     }
          //   })
          // }.bind(this)
        },
        {
          align: 'center',
          title: '电核结果',
          key: 'resultCode'
          // render: function (h, params) {
          //   const vm = this
          //   return h('Select', {
          //     props: {
          //       value: params.row.resultCode
          //     },
          //     on: {
          //       'on-change' (value) {
          //         vm.initTempPhoneChkDataObject(params)
          //         vm.$set(vm.tempPhoneChkData[params.index], 'resultCode', value)
          //       }
          //     }
          //   }, this.selectPhoneChkResultBasicData.map(function (item) {
          //     return h('Option', {
          //       props: {
          //         value: item.code
          //       }
          //     }, item.name)
          //   })
          //   )
          // }.bind(this)
        },
        {
          align: 'center',
          title: '电核备注',
          key: 'remark'
          // render: function (h, params) {
          //   const vm = this
          //   return h('Input', {
          //     props: {
          //       type: 'text',
          //       value: params.row.remark
          //     },
          //     on: {
          //       'on-change' (e) {
          //         vm.initTempPhoneChkDataObject(params)
          //         vm.$set(vm.tempPhoneChkData[params.index], 'remark', e.target.value)
          //       }
          //     }
          //   })
          // }.bind(this)
        },
        {
          align: 'center',
          title: '操作人',
          key: 'updatedBy'
        },
        {
          align: 'center',
          title: '创建时间',
          key: 'createdDate'
        },
        {
          align: 'center',
          title: '电核时间',
          key: 'startTime'
        },
        {
          align: 'center',
          title: '通话时间',
          key: 'duration'
        },
        {
          align: 'center',
          title: '操作',
          width: 80,
          key: 'action',
          render: (h, params) => {
            var vm = this
            return h('div', [
              h('Button', {
                props: {
                  type: 'primary',
                  size: 'small',
                  disabled: true
                },
                on: {
                  click: () => {
                    vm.dial(params)
                  }
                }
              }, ' 拨号')
            ])
          }
        }
      ],
      phoneChkData: [],
      tempPhoneChkData: [],
      phoneChkEmptyRowData: {
        pohneTypeCode: null,
        contactName: null,
        phoneNo: null,
        resultCode: null,
        remark: null,
        updatedBy: null,
        createdDate: null,
        startTime: null,
        duration: null
      },
      selectEmployTypeBasicData: [],
      selectMaritalStatusBasicData: [],
      selectEducationLevelBasicData: [],
      selectLiveTypeBasicData: [],
      selectProvinceBasicData: [],
      selectCityBasicData: [],
      selectRegionBasicData: [],
      selectCompanyTypeBasicData: [],
      selectWorkTimeTypeBasicData: [],
      selectIncomeTypeBasicData: [],
      // selectRelationBasicData: [],
      // selectRelationOtherBasicData:[],
      selectRelationAllBasicData: [],
      selectPhoneChkResultBasicData: [],
      selectSecondCareerBasicData: [],
      selectThridCareerBasicData: [],
      selectEnterpriseScaleBasicData: [],
      selectLoanInvestmentBasicData: [],
      selectInvestmentDetailBasicData: []
    }
  },
  methods: {
    initpage () {
      this.initSelectData()
    },
    // 初始化下拉列表数据
    initSelectData () {
      var vm = this
      this.$ajax.post(this.baseUrl + 'approve/process/task_process/service/getCustomerBasicDatas').then(re => {
        var data = re.data
        var code = data.code
        var message = data.message
        if (code !== 'success') {
          this.$Message.warning(message)
          return
        }
        vm.selectEmployTypeBasicData = data.data.employTypeBasicData
        vm.selectMaritalStatusBasicData = data.data.maritalStatusBasicData
        vm.selectEducationLevelBasicData = data.data.educationLevelBasicData
        vm.selectLiveTypeBasicData = data.data.liveTypeBasicData
        vm.selectProvinceBasicData = data.data.provinceBasicData
        vm.selectCityBasicData = data.data.cityBasicData
        vm.selectRegionBasicData = data.data.regionBasicData
        vm.selectCompanyTypeBasicData = data.data.companyTypeBasicData
        vm.selectWorkTimeTypeBasicData = data.data.workTimeTypeBasicData
        vm.selectIncomeTypeBasicData = data.data.incomeTypeBasicData
        // vm.selectRelationBasicData = data.data.relationBasicData
        // vm.selectRelationOtherBasicData = data.data.relationOtherBasicData;
        // if(vm.selectRelationBasicData && vm.selectRelationOtherBasicData){
        //     vm.selectRelationAllBasicData = vm.selectRelationBasicData.concat(vm.selectRelationOtherBasicData);
        // }
        vm.selectRelationAllBasicData = data.data.relationBasicData
        vm.selectPhoneChkResultBasicData = data.data.phoneChkResultBasicData
        vm.selectSecondCareerBasicData = data.data.twoCareerTypeBasicData
        vm.selectThridCareerBasicData = data.data.threeCareerTypeBasicData
        vm.selectEnterpriseScaleBasicData = data.data.enterpriseScaleTypeBasicData
        vm.initFormData()
      }).catch(er => {

      })
    },
    // 初始化表单数据
    initFormData () {
      var vm = this
      var url = this.baseUrl + 'approve/process/task_process/service/getCustomerDetail/' + this.$route.query.loanId
      this.$ajax.get(url).then(re => {
        var data = re.data
        var code = data.code
        var message = data.message
        if (code !== 'success') {
          this.$Message.warning(message)
          return
        }
        vm.customerInfoForm = data.data
        vm.customerInfoForm.custSex = vm.customerInfoForm.custSex === 1 ? '男' : '女'
        vm.customerInfoForm.customerType = '' + vm.customerInfoForm.customerType
        vm.customerInfoForm.eductionLevelId = '' + vm.customerInfoForm.eductionLevelId
        vm.customerInfoForm.custCardStartTime = vm.customerInfoForm.custCardStartTime ? new Date(vm.customerInfoForm.custCardStartTime) : ''
        vm.customerInfoForm.custCardEndTime = vm.customerInfoForm.custCardEndTime ? new Date(vm.customerInfoForm.custCardEndTime) : ''
        vm.customerInfoForm.custBirthDate = vm.customerInfoForm.custBirthDate ? new Date(vm.customerInfoForm.custBirthDate) : ''
        vm.customerInfoForm.homeRentStartDate = vm.customerInfoForm.homeRentStartDate ? new Date(vm.customerInfoForm.homeRentStartDate) : ''
        vm.customerInfoForm.homeRentEndDate = vm.customerInfoForm.homeRentEndDate ? new Date(vm.customerInfoForm.homeRentEndDate) : ''
        vm.customerInfoForm.companyRegistrationDate = vm.customerInfoForm.companyRegistrationDate ? new Date(vm.customerInfoForm.companyRegistrationDate) : ''

        vm.renderInvestmentDetailList(vm.customerInfoForm.loanInvestmentCode)

        vm.curHomeAry = [vm.customerInfoForm.curHomeProvince, vm.customerInfoForm.curHomeCity, vm.customerInfoForm.curHomeCounty]
        vm.curCompanyAry = [vm.customerInfoForm.companyProvince, vm.customerInfoForm.companyCity, vm.customerInfoForm.companyCounty]

        vm.contactData = data.data.contacts
        vm.loadContactData()
        vm.contactChkData = data.data.contactChks
        vm.loadContactChkData()
        vm.phoneChkData = data.data.phoneChks
        vm.loadPhoneChkData()
      }).catch(er => {

      })
    },
    // 初始化联系人数组数据对象
    // initTempContactDataObject (params) {
    //   if (!this.tempContactData[params.index]) {
    //     this.tempContactData[params.index] = {}
    //   }
    // },
    // // 添加联系人行
    // addContactDefaultEmptyRow () {
    //   this.contactData = this.$util.cloneObject(this.tempContactData)
    //   this.contactData.push(this.$util.cloneObject(this.contactEmptyRowData))

    // this.contactChkData = this.$util.cloneObject(this.tempContactChkData);
    // this.contactChkData.push(this.$util.cloneObject(this.contactChkEmptyRowData));
    // this.tempContactChkData = this.$util.cloneObject(this.contactChkData);
    // },
    // 添加联系人行时，动态渲染客户关系列表
    // renderRelationSelect (h, params) {
    //   const vm = this
    //   // if(params.row.contactType === 0){
    //   return vm.selectRelationBasicData.map(function (item) {
    //     return h('Option', {
    //       props: {
    //         value: item.code
    //       }
    //     }, item.name)
    //   })
    // }else if(params.row.contactType === 1){
    //     return vm.selectRelationOtherBasicData.map(function(item){
    //         return h('Option',{
    //             props:{
    //                 value:item.code
    //             }
    //         },item.name);
    //     })
    // }else{
    //     return vm.selectRelationAllBasicData.map(function(item){
    //         return h('Option',{
    //             props:{
    //                 value:item.code
    //             }
    //         },item.name);
    //     })
    // }
    // },
    // 初始化联系人验证结果数组数据对象
    initTempContactChkDataObject (params) {
      if (!this.tempContactChkData[params.index]) {
        this.tempContactChkData[params.index] = {}
      }
    },
    // 初始化电核录入数组数据对象
    initTempPhoneChkDataObject (params) {
      if (!this.tempPhoneChkData[params.index]) {
        this.tempPhoneChkData[params.index] = {}
      }
    },
    addPhoneChkDefaultEmptyRow () {
      this.phoneChkData = this.$util.cloneObject(this.tempPhoneChkData)
      this.phoneChkData.push(this.$util.cloneObject(this.phoneChkEmptyRowData))
    },
    // 加载联系人信息表格数据
    loadContactData () {
      if (this.contactData && this.contactData.length > 0) {
        this.tempContactData = this.$util.cloneObject(this.contactData)
      }
    },
    // 加载联系人验证结果表格数据
    loadContactChkData () {
      // 默认添加一个'本人'验证行记录
      // var row = this.$util.cloneObject(this.contactChkEmptyRowData)
      // row.contactName = '本人'
      // row.loanApplyContactId = -1
      // var hasSelf = false
      if (this.contactChkData && this.contactChkData.length > 0) {
        for (var i in this.contactChkData) {
          if (this.contactChkData[i].loanApplyContactId === -1) {
            // hasSelf = true
            break
          }
        }
      }
      // if (!hasSelf) {
      //   this.contactChkData.unshift(row)
      // }
      this.tempContactChkData = this.$util.cloneObject(this.contactChkData)
    },
    // 加载电核录入表格数据
    loadPhoneChkData () {
      if (this.phoneChkData && this.phoneChkData.length > 0) {
        this.tempPhoneChkData = this.$util.cloneObject(this.phoneChkData)
      }
    },
    submitForm () {
      // 将临时表格数据复制给表单
      this.contactData = this.$util.cloneObject(this.tempContactData)
      this.contactChkData = this.$util.cloneObject(this.tempContactChkData)
      this.phoneChkData = this.$util.cloneObject(this.tempPhoneChkData)
      this.customerInfoForm.contacts = this.contactData
      this.customerInfoForm.contactChks = this.contactChkData
      this.customerInfoForm.phoneChks = this.phoneChkData
      // 城市级联赋值
      this.customerInfoForm.curHomeProvince = this.curHomeAry[0]
      this.customerInfoForm.curHomeCity = this.curHomeAry[1]
      this.customerInfoForm.curHomeCounty = this.curHomeAry[2]
      this.customerInfoForm.companyProvince = this.curCompanyAry[0]
      this.customerInfoForm.companyCity = this.curCompanyAry[1]
      this.customerInfoForm.companyCounty = this.curCompanyAry[2]

      var vm = this
      var params = this.customerInfoForm
      this.$ajax.post(this.baseUrl + 'approve/process/task_process/service/saveCustomerInfo', params).then(re => {
        var data = re.data
        var code = data.code
        var message = data.message
        if (code !== 'success') {
          this.$Message.warning(message)
          return
        }
        vm.contactData = data.data.contacts
        vm.loadContactData()
        vm.contactChkData = data.data.contactChks
        vm.loadContactChkData()
        vm.phoneChkData = data.data.phoneChks
        vm.loadPhoneChkData()
        this.$Message.success(message)
      }).catch(er => {

      })
    },
    chooseItem (item, e) {
      this.itemName = s
    },
    // 拨号
    dial (params) {
      var vm = this
      this.$ajax.post(this.baseUrl + 'approve/process/task_process/service/getLoginUserInfo').then(re => {
        var data = re.data
        var code = data.code
        var message = data.message
        if (code !== 'success') {
          this.$Message.warning(message)
          return
        }
        var shortPhoneNo = data.data.shortPhoneNo
        if (shortPhoneNo && shortPhoneNo !== '') {
          var backUrl = vm.baseUrl + 'approve/process/task_process/service/writeCallInfo/' + params.row.id
          $.ajax({
            url: 'http://10.0.17.200:9800/SmartWS.php',
            data: {
              'Act': 'Call_Originate',
              'Ext': shortPhoneNo,
              'Dest': params.row.phoneNo,
              // 'Area':area,
              // 回写地址
              'Writeback': backUrl
            },
            dataType: 'jsonp',
            jsonp: 'jsonpCallback',
            jsonpCallback: 'SmartWS',
            success: function (retData, textStatus, jqXHR) {
              if (retData.retinfo === 'SUCCESS') {
                vm.$Message.success('已成功拨通对方号码，请拿起话机')
              } else {
                vm.$Message.warning('未拨通')
              }
            }
          })
        } else {
          this.$Message.warning('您没有注册短号')
        }
      }).catch(er => {

      })
    },
    renderInvestmentDetailList (val) {
      this.selectInvestmentDetailBasicData = loanInvestmentData.loanInvestmentChildrenData[val]
    }
  },
  computed: {
    type () { // 0.未面签   1.正在面签   3 面签已过号      5面签退回
      return parseInt(this.$route.query.type)
    }
  },
  mounted () {
    this.selectLoanInvestmentBasicData = loanInvestmentData.loanInvestmentParentData
  },
  created () {
    this.$ajax = this.$util.ajax()
    this.initFormData()
    // if(this.taskParams.customerInfo){
    //     this.initpage();
    // }
  },
  watch: {
    // 点击tab页签，加载数据，只加载一次
    'taskParams.customerInfo' (v) {
      if (v) {
        // this.initpage()
      }
    }
  },
  props: {
    taskParams: Object
  }
}
</script>
